#include <stdio.h>
#include <stdlib.h>
#include "matrix.h"

void change(double *matrix, int rows, int cols, double constant, char sign){
	if(sign =='+')
	{
		for (int i = 0; i < rows; i++) 
		{
            for (int j = 0; j < cols; j++) 
			{
               matrix[i * cols + j] += constant;  // 将常数加到矩阵的每个元素上
            }
        }
	}
	else if(sign =='-')
	{
		for (int i = 0; i < rows; i++) 
		{
            for (int j = 0; j < cols; j++) 
			{
               matrix[i * cols + j] -= constant;  // 将常数减到矩阵的每个元素上
            }
        }
	}
	else if(sign =='*')
	{
	   	for (int i = 0; i < rows; i++) 
	    {
            for (int j = 0; j < cols; j++) 
			{
               matrix[i * cols + j] *= constant;  // 将常数乘到矩阵的每个元素上
            }
        }
	}
	for (int i = 0; i < rows; i++) 
	{
        for (int j = 0; j < cols; j++) 
		{
            printf("%.2lf ", matrix[i * cols + j]);
        }
        printf("\n");
    }
}
